<?php 
$m = $this->get_data('m');
$a = $this->get_data('a');
$node_id = $this->get_data('node_id');
$thumbnail = $this->get_data('thumbnail');
if (empty($thumbnail)) $thumbnail = 'img/icon/blueprint.png';
$parent_id = ($this->has_data('parent_id')) ? (int) $this->get_data('parent_id') : (int) tos_http_get('parent_id');
?>
<?php if ($node_id > 0):?>
<input id="current_node_id" type="hidden" value="<?php echo $node_id;?>" />
<?php endif;?>
<h1 id="page_caption"><?php $this->write('page_caption')?></h1>
<div id="ne">
    <div class="box">
    <form accept-charset="utf-8" name="node_form" method="post" action="<?php echo tos_router_url(array('m'=> $m, 'a'=>$a, 'node_id'=>$node_id,'parent_id' => tos_http_get('parent_id')));?>">
        <div id="prev_ne">
            <div class="bar">
                <input id="keyword_input" type="text" class="text" value="" />
                <a id="keyword_search_bt" href="javascript:;"><img src="<?php echo tos_cdn_url('img/icon/arrow3_e.png');?>" alt=""/></a>
            </div>
            <a href="javascript:;" onclick="clear_parent_node();">Clear Parent Node</a>
            <div id="parent_node_container">
            <?php if ($parent_id > 0) m('node')->block_node($parent_id, array('description_length' => 80))->display();?>
            </div>
            <div id="keyword_container"></div>
            <div id="prev_nodes_container"></div>
        </div>
        <div class="outline">
            <div class="thumbnail"><?php echo tos_img($thumbnail, 0, 0, array('id' => 'node_thumbnail'));?></div>
            <div class="wording">
                <div>
                    Caption:<br />
                    <input type="text" class="text required" name="caption" value="<?php $this->write('caption');?>" />
                </div>
                <div>
                    Url segment:<br />
                    <input type="text" class="text required" name="url_segment" value="<?php $this->write('url_segment');?>" />
                </div>
                <div>
                    Rank:<br />
                    <input type="text" class="text" name="rank" value="<?php $this->write('rank');?>" />
                </div>
                <div>
                    Description:<br />
                    <textarea name="description"><?php $this->write('description')?></textarea>
                </div>
            </div>
        </div>
        <div class="content">
        <?php $this->display_box();?>
        </div>
    </form>
    <div class="submit">
    <form accept-charset="utf-8" name="node_form_submit" method="post" action="<?php echo tos_router_url(array('m'=> $m, 'a'=>$a, 'node_id'=>$node_id, 'parent_id' => tos_http_get('parent_id')));?>">
        <input type="submit" class="submit" name="submit" value="Save" /> 
        <input type="submit" class="submit" name="submit" value="Save & View" />
        <a href="<?php echo tos_router_url(array('a' => 'display', 'm' => 'node', 'node_id' => $node_id, 'parent_id' => $parent_id));?>">Cancel</a>
    </form>
    </div>
    </div>
</div>
<?php m('node')->view('node/edit', array('keyword_list' => $this->get_data('keyword_list')))->display('js');?>
<?php //m('node')->block_edit_script(array('keyword_list' => $this->get_data('keyword_list')))->display('js');?>